package com.tjbank.cssys.web.controller;

import com.tjbank.cssys.web.service.CkUserService;
import com.tjbank.cssys.web.util.CommonResult;
import com.tjbank.cssys.web.util.GetUserCodeFromToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;

@RestController
@RequestMapping("/user/info")
public class CkUserController {

    @Autowired
    private CkUserService ckUserService;


    @RequestMapping("/getBranch")
    public CommonResult getBranchAndSub (HttpServletRequest request){
        CommonResult result = null;
        try {
            String userCode= GetUserCodeFromToken.getUserCode(request);
            HashMap<String, Object> userBranchAndSub = ckUserService.getUserBranchAndSub(userCode);
            result = CommonResult.success(userBranchAndSub);
        } catch (Exception e) {
            result = CommonResult.failed();
        }
        return  result;
    }

}
